package com.lingnan.blog.mapper;

import com.lingnan.blog.entity.Friend;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface FriendMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(Friend record);

    int insertSelective(Friend record);

    Friend selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(Friend record);

    int updateByPrimaryKey(Friend record);

    /**
     * 查询他人的总数
     * @param uid
     * @return
     */
    @Select("select count(*) from friend where u_id = #{uid} ")
    Integer countByUid(Integer uid);

    /**
     * 查询关注我的总数
     * @param fid
     * @return
     */
    @Select("select count(*) from friend where f_id = #{fid} ")
    Integer countByFid(Integer fid);

    @Select("select * from friend where u_id = #{uid} and f_id = #{fid} ")
    Friend selectByUIdAndFId(@Param("uid") Integer uid, @Param("fid") Integer fid);
}